package com.taomus.mytools.simplec.generate;

import java.util.Arrays;

public class Tuples {
	private WordEnum opcode;
	private Object t1;
	private Object t2;
	private Object t3;
	
	public Tuples(WordEnum opcode, Object t1) {
		super();
		this.opcode = opcode;
		this.t1 = t1;
	}
	public Tuples(WordEnum opcode, Object t1, Object t2) {
		super();
		this.opcode = opcode;
		this.t1 = t1;
		this.t2 = t2;
	}
	public Tuples(WordEnum opcode, Object t1, Object t2,Object t3) {
		super();
		this.opcode = opcode;
		this.t1 = t1;
		this.t2 = t2;
		this.t3 = t3;
	}

	public WordEnum getOpcode() {
		return opcode;
	}

	public void setOpcode(WordEnum opcode) {
		this.opcode = opcode;
	}

	public Object getT1() {
		return t1;
	}

	public void setT1(Object t1) {
		this.t1 = t1;
	}

	public Object getT2() {
		return t2;
	}

	public void setT2(Object t2) {
		this.t2 = t2;
	}

	@Override
	public String toString() {
		StringBuilder info = new StringBuilder("(");
		info.append(opcode);
		info.append(",");
		info.append(t1);
		if(t2 != null){
			info.append(",");
			info.append(t2);
		}
		if(t3 != null){
			info.append(",");
			info.append(t3);
		}
		info.append(")");
		return info.toString();
	}
	private static void print(Tuples tp){
		System.out.println(tp);
	}
	public static void main(String[] args){
		Tuples tp = new Tuples(WordEnum.VAR,new Token(WordEnum.ID,"a"),new Token(WordEnum.NUMBER,"10"));
		Tuples func = new Tuples(WordEnum.FUNC,new Token(WordEnum.ID,"c"),
				Arrays.asList(new Tuples(WordEnum.VAR,new Token(WordEnum.ID,"b"),new Token(WordEnum.NUMBER,"20")),
						new Tuples(WordEnum.IF,new Tuples(WordEnum.GT,new Token(WordEnum.ID,"a"),new Token(WordEnum.ID,"b")),
								Arrays.asList(new Tuples(WordEnum.VAR,new Token(WordEnum.ID,"a"),new Token(WordEnum.NUMBER,"30")),new Tuples(WordEnum.FRET,new Token(WordEnum.ID,"a"))),
								Arrays.asList(new Tuples(WordEnum.MOV,new Token(WordEnum.ID,"b"),new Token(WordEnum.NUMBER,"20")),new Tuples(WordEnum.FRET,new Token(WordEnum.ID,"b")))
								)
						)
				);
		print(tp);
		print(func);
	}
}
